﻿using Informator.Presentation.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml.Linq;


namespace Informator.Presentation.Nastava_i_vezbe
{
    /// <summary>
    /// Interaction logic for Predmet.xaml
    /// </summary>
    public partial class Predmet : UserControl
    {
        private double MaxWidth;
        private PredmetModel model;
        private Color LightBlue = Brushes.Azure.Color;
        private Color Red = Brushes.Red.Color;
        public void changeTime()
        {
            lbl.Content = model.PocetakPredavanja.ToString() + " - " + model.KrajPredavanja.ToString();
            Mesto.Content = model.SalaNaziv;
            int minut = (int)(model.KrajPredavanja - DateTime.Now.TimeOfDay).TotalMinutes;
            int sekunda = (int)(model.KrajPredavanja - DateTime.Now.TimeOfDay).Seconds;
            if (sekunda >= 10 && minut >= 10)
                lblostalovreme.Content = minut + " : " + sekunda;
            else if(sekunda <10 && minut <10)
                lblostalovreme.Content = "0" + minut + " : " + "0" + sekunda;
            else if(sekunda <10 && minut>=10)
                lblostalovreme.Content = minut + " : " + "0" + sekunda;
            else
                lblostalovreme.Content = "0" + minut + " : " +  sekunda;

            //VremeKraj.Width = model.ProsloVreme * (model.MaxWidth / model.TrajanjePredmeta.TotalSeconds);
            VremeKraj.Value = model.KrajPredavanja.TotalMinutes - DateTime.Now.TimeOfDay.TotalMinutes;
        }
        public Predmet(PredmetModel Model)
        {
            InitializeComponent();
            model = Model;
            ImePredmeta.Text = model.ImePredmeta;
            MaxWidth = model.MaxWidth - Predmetnaziv.ActualWidth;
            Body.Width = MaxWidth;
            VremeKraj.Minimum = 0;
            VremeKraj.Maximum = model.TrajanjePredmeta.TotalMinutes;
            changeTime();
        }
    }
}
